package se.kayarr.cardplay.gameplay;

import lombok.Getter;


public class ActionCard extends Card {
	public static final String TYPE_SYMBOL = "A";
	
	@Getter private int targetFlags = Targetable.NONE;
	
	public void setTargetFlags(int targetFlags) {
		checkMutable();
		this.targetFlags = targetFlags;
	}
	
	public void setTargetFlagValue(int targetFlags, boolean value) {
		checkMutable();
		if(value) this.targetFlags &= ~targetFlags;
		else targetFlags |= targetFlags;
	}
	
	public boolean allTargetFlagsSet(int targetFlags) {
		return ((this.targetFlags & targetFlags) == targetFlags);
	}
	
	public boolean anyTargetFlagsSet(int targetFlags) {
		return ((this.targetFlags & targetFlags) != 0);
	}
	
	public String getTypeSymbol() {
		return TYPE_SYMBOL;
	}
	
	public ActionCard(int numericId) {
		super(numericId);
	}

	@Override
	public Instance newInstance(Session session, Player owner) {
		return new Instance(session, owner);
	}
	
	public class Instance extends Card.Instance {
		public ActionCard getCard() {
			return ActionCard.this;
		}
		
		protected Instance(Session session, Player owner) {
			super(session, owner);
			
			onInit();
		}
		
		public void onUse(Player user, Targetable target) {
			invokeFunction("onUse", this, user, target);
		}
	}
}
